﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using TarreOA.TarreOAModels;
using TarreOA.TarreOABLL;

public partial class admin_AttendanceInfoShow : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            AttendanceTime attendanceTime = AttendanceTimeManager.showIt(Server.MapPath(@"~/companyFiles/AttendanceTime.xml"));
            AttendanceInfo attendanceInfo = AttendanceInfoManager.FindByAttendanceInfoId(Convert.ToInt32(Request.QueryString["aid"]));
            lblAttendanceUser.Text = attendanceInfo.AttendanceUser.UserName;
            lblAttendanceDate.Text = attendanceInfo.AttendanceTime.ToShortDateString();
            string remark = "";
            if (attendanceInfo.AttendanceComeAM!=null && attendanceInfo.AttendanceComeAM.ToShortDateString()!="0001/1/1")
            {
                DateTime checkTime = Convert.ToDateTime(attendanceTime.ComeAM);
                remark += "\r\r上午上班：" + attendanceInfo.AttendanceComeAM.ToShortTimeString() + (attendanceInfo.AttendanceComeAM > new DateTime(attendanceInfo.AttendanceTime.Year, attendanceInfo.AttendanceTime.Month, attendanceInfo.AttendanceTime.Day, checkTime.Hour, checkTime.Minute, 0) ? " 迟到" : " 正常");
                remark += "\r\r备注：" + attendanceInfo.AttendanceComeAMRemark;
            }
            if(attendanceInfo.AttendanceBackAM!=null && attendanceInfo.AttendanceBackAM.ToShortDateString()!="0001/1/1")
            {
                DateTime checkTime = Convert.ToDateTime(attendanceTime.BackAM);
                remark += "\r\r上午下班：" + attendanceInfo.AttendanceBackAM.ToShortTimeString() + (attendanceInfo.AttendanceBackAM > new DateTime(attendanceInfo.AttendanceTime.Year, attendanceInfo.AttendanceTime.Month, attendanceInfo.AttendanceTime.Day, checkTime.Hour, checkTime.Minute, 0) ? " 正常" : " 早退");
                remark += "\r\r备注：" + attendanceInfo.AttendanceBackAMRemark;
            }
            if (attendanceInfo.AttendanceComePM != null && attendanceInfo.AttendanceComePM.ToShortDateString() != "0001/1/1")
            {
                DateTime checkTime = Convert.ToDateTime(attendanceTime.ComePM);
                remark += "\r\r下午上班：" + attendanceInfo.AttendanceComePM.ToShortTimeString() + (attendanceInfo.AttendanceComePM > new DateTime(attendanceInfo.AttendanceTime.Year, attendanceInfo.AttendanceTime.Month, attendanceInfo.AttendanceTime.Day, checkTime.Hour, checkTime.Minute, 0) ? " 迟到" : " 正常");
                remark += "\r\r备注：" + attendanceInfo.AttendanceComePMRemark;
            }
            if (attendanceInfo.AttendanceBackPM != null && attendanceInfo.AttendanceBackPM.ToShortDateString() != "0001/1/1")
            {
                DateTime checkTime = Convert.ToDateTime(attendanceTime.BackPM);
                remark += "\r\r下午下班：" + attendanceInfo.AttendanceBackPM.ToShortTimeString() + (attendanceInfo.AttendanceBackPM > new DateTime(attendanceInfo.AttendanceTime.Year, attendanceInfo.AttendanceTime.Month, attendanceInfo.AttendanceTime.Day, checkTime.Hour, checkTime.Minute, 0) ? " 正常" : " 早退");
                remark += "\r\r备注：" + attendanceInfo.AttendanceBackPMRemark;
            }
            txtRemark.Text = remark;
            Session.Remove("AttendanceInfo");
        }
    }
}
